from pydantic import BaseModel, Field
from typing import Optional, List
from datetime import datetime

# 基础数据模型
class Item(BaseModel):
    id: int
    name: str
    description: Optional[str] = None
    price: float
    is_available: bool = True

# 创建商品请求模型
class ItemCreate(BaseModel):
    name: str = Field(..., min_length=1, max_length=100)
    description: Optional[str] = Field(None, max_length=500)
    price: float = Field(..., gt=0)
    is_available: bool = True

# 更新商品请求模型
class ItemUpdate(BaseModel):
    name: Optional[str] = Field(None, min_length=1, max_length=100)
    description: Optional[str] = Field(None, max_length=500)
    price: Optional[float] = Field(None, gt=0)
    is_available: Optional[bool] = None

# 用户模型
class User(BaseModel):
    id: int
    username: str
    email: str
    is_active: bool = True
    created_at: datetime

# API响应模型
class ApiResponse(BaseModel):
    success: bool
    message: str
    data: Optional[dict] = None